<template>
  <v-table
    :pageSize="pageSize"
    :page="page"
    :tableConfig="tableConfig"
    :tableData="tableData"
    :total="total"
    @findData="getTableData"
    @getTableData="getTableData"
    @searhData="setSearhData"
    @selectData="setSelectData"
    @upData="getTableData"
    :hasEdit="false"
    ref="table"
  ></v-table>
</template>

<script>
import table from "commons/Table";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "ship_carton",
  mixins: [baseMixin],
  props: {
    data: {
      type: Object,
    },
  },
  data() {
    return {
      tableConfig: [
        {
          label: this.$t("out.orderkey1"),
          prop: "orderkey",
          input: "input",
        },
        {
          label: this.$t("out.externorderkey2"),
          prop: "externorderkey",
          input: "input",
        },
        {
          label: this.$t("out.rtxexpresskey"),
          prop: "expresskey",
          input: "input",
        },
        {
          label: this.$t("out.palletkey"),
          prop: "dropid",
          input: "input",
        },
        {
          label: this.$t("out.totalqty1"),
          prop: "totalqty",
          input: "input",
        },
        {
          label: this.$t("out.totalcube"),
          prop: "cube",
          input: "input",
        },
        {
          label: this.$t("in.standardlpn"),
          prop: "caseid",
          input: "input",
        },
        {
          label: this.$t("config.shipper"),
          prop: "storerkey",
          input: "input",
        },
        {
          label: this.$t("out.cartontype"),
          prop: "cartontype",
          input: "input",
        },
      ],
      tableData: [],
      pageSize: 10,
      page: 1,
      total: 10,
      searhData: {},
    };
  },
  methods: {
    //获取table数据
    async getTableData(page, data) {
      try {
        let res = await this.$api.post(
          `/queryShipMentCartonList/${this.$store.state.wms}/${this.data.argument.shippingkey}/${page}`,
          data
        );
        
          this.loading = false;
          this.tableData = res.page.list;
          this.page = res.page.curpage;
          this.pageSize = res.page.pageSize;
          this.total = res.page.total;
        
      } catch (e) {
        this.$message.error(e);
      }
    },
    //搜索值
    setSearhData(data, up) {
      if (!up) {
        this.searhData = data;
      } else {
        this.searhData = data;
        this.getTableData(1, this.searhData);
      }
    },
    //选中的数据
    setSelectData(data) {
      this.$parent.setSelectData(data);
    },
  },
  mounted() {
    this.getTableData(1, {});
  },
  components: {
    "v-table": table,
  },
};
</script>

<style scoped></style>
